import { viteMockServe } from 'vite-plugin-mock'

export function mockPlugin(configEnv, resolve) {
	return viteMockServe({
		mockPath: 'mock',
		localEnabled: configEnv.command === 'serve',
		prodEnabled: configEnv.command !== 'serve',
		injectCode: `
			import { setupProdMockServer } from ${resolve('./mock')};
			setupProdMockServer();
		`,
	})
}